﻿@Cofe ?= {}

$ = jQuery
Event = Cofe.Event
utils = Cofe.utils

# CONTROLLER - Represents an event.
#     params - @el, @templateKey (css template) , @event (FeedEvent model)
class EventItem extends Spine.Controller
  constructor : (dic) ->                   # Overridable parameters.            
    super        

  tag : "li"
      
  init: ->     

  EventItem.fromEvent = (event) ->
    data = $.parseJSON(event.description)    
    new EventItem({ event : event, data : data })

  render: (templateKey) =>     
    @el.html(@template(templateKey))      
  
  remove: =>
    @el.remove()

  template: (templateKey) ->
    if templateKey is undefined then throw "templateKey not specified"
    templateKey.render(@event)
  
   
Cofe.EventItem = EventItem